{include file="public/header" /}
<span class="layui-breadcrumb">
  <a href="javascript:;">设置</a>
  <a href="javascript:;">插入文件</a>
  <a><cite>列表</cite></a>
</span>
<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-body">
      <div style="color:#FF5722">询问数据,名字和email必填,查询的开始时间(包含此时间,大于等于此时间),结束时间(不包含该时间,小于此时间),故两个时间不能一样</div>
      <div class="layui-form">

        <div class="layui-form-item" style='margin-top:20px'>
          <div class="layui-inline">
            <label class="layui-form-label">开始时间</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" id="start_time" placeholder="yyyy-MM-dd">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">结束时间</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" id="end_time" placeholder="yyyy-MM-dd">
            </div>
          </div>
          <div class="layui-inline">
            <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="sear()">查询</button>
            <a href="{:url('Subscribe/index')}?nav=set-subscribe" class="layui-btn layui-btn-sm layui-btn-danger">清空</a>
          </div>
        </div>

        <table class="layui-hide" id="test" lay-filter="test"></table>

      </div>

    </div>
  </div>
</div>

{include file="/public/footer" /}
<script>
  layui.use('table', function(){
    var table = layui.table;

    table.render({
      elem: '#test'
      ,url:'/admin/Subscribe/get_data/'
      ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
      ,defaultToolbar: ['filter', 'exports', 'print']
      ,title: '询盘数据表'
      ,cols: [[
        {field:'email', title:'邮件',}
        ,{field:'ip', title:'ip'}
        ,{field:'create_time', title:'发送时间',width:160}
        ,{field:'status', title:'状态',width:60}
      ]]

      ,page: true

    });



  });

  function del(id){
    layer.confirm('你确定要删除吗', {
      btn: ['确定','取消'] //按钮
    }, function(){
      layer.load();
      $.post("{:url('Subscribe/del')}",{id:id},function(res){
        if(res.status=='0'){
          layer.closeAll('loading');
          layer.msg(res.msg);
        }
        if(res.status=='1'){
          layer.msg(
                  res.msg,{icon: 1,time: 600},
                  function(){
                    layer.closeAll('loading');
                    location.href=location.href;
                  });
        }
      })
    });
  }

  //日期
  layui.use('laydate', function(){
    var laydate = layui.laydate;
    laydate.render({
      elem: '#start_time'
    });
    laydate.render({
      elem: '#end_time'
    });
  })
  /*查询*/
  function sear(){
    /*layer.load();*/
    var start_time=$.trim($("#start_time").val());
    var end_time=$.trim($("#end_time").val());
    if(start_time==''&&end_time==''){
      /*layer.closeAll('loading');*/
      layer.msg('请选择开始时间或结束时间');
      return false;
    }
    window.location.href="{:url('Subscribe/index')}"+"?nav=set-subscribe&start_time="+start_time+"&end_time="+end_time;
  }

  function look_comments(con){
    $.post("{:url('Subscribe/get_one_data')}",{id:con},function(res){
      layer.open({
        title:'留言信息',
        type: 1,
        skin: 'layui-layer-rim', //加上边框
        area: ['420px', '240px'], //宽高
        content: "<div style='padding:5px;'>"+res.comments+"</div>"
      });
    })

  }

  function look_url(con){
    $.post("{:url('Subscribe/get_one_data')}",{id:con},function(res){
      layer.open({
        title:'路径信息',
        type: 1,
        skin: 'layui-layer-rim', //加上边框
        area: ['420px', '240px'], //宽高
        content: "<div style='padding:5px;'><div style='color:#FF5722'>停留页面:指最终发送询盘的页面。来源页面:指进入停留页面之前的页面</div><div>停留页面:"+res.nowurl+"</div><div>来源页面:"+res.lasturl+"</div></div>"
      });
    })
  }

</script>
